package bm.com.project.server.project.controller;

import bm.com.framework.common.config.EnumRoute;
import bm.com.project.server.VerifyController;
import bm.com.project.server.common.dto.SearchBaseDTO;
import bm.com.project.server.project.entity.BmProjectEntity;
import bm.com.project.server.project.service.BmProjectService;
import bm.com.framework.common.resp.ResultVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(EnumRoute.ProjectRoute.BASE)
public class ProjectController extends VerifyController {

    @Resource
    BmProjectService bmProjectService;

    /**
     * 创建项目
     * @param bmProject
     * @return
     */
    @PostMapping(EnumRoute.ProjectRoute.Project.SAVE)
    public ResultVO save(@RequestBody BmProjectEntity bmProject) {
//        ValidatorUtils.validateEntity(bmProject);
        return bmProjectService.saveProject(bmProject);
    }

    /**
     * 获取项目列表
     * @return
     */
    @PostMapping(EnumRoute.ProjectRoute.Project.GET_LIST)
    public ResultVO getList(@RequestBody SearchBaseDTO searchBaseDTO) {
        return bmProjectService.getList(searchBaseDTO);
    }

    /**
     * 获取项目详情
     * @param projectId
     * @return
     */
    @PostMapping(EnumRoute.ProjectRoute.Project.GET_DETAIL)
    public ResultVO getDetail(
            @RequestParam(name = "projectId") String projectId
    ) {
        return bmProjectService.getDetail( projectId);
    }
}
